<template>
	<uni-header title="公告"></uni-header>
	<view class="list">
		<view class="item" v-for="item in list" @click="showModel(item)">
			<view class="left">
				<image src="/static/messagfe.png" mode=""></image>
				<text>{{item.dictValue}}</text>
			</view>
			<view class="right">
				<text>{{item.dictKey}}</text>
				<image src="../../static/right.png" mode=""></image>
			</view>
		</view>
	</view>
	<view class="model" v-if="modelState">
		<view class="content">
			<view class="header">
				<text>详情</text>
				<image src="../../static/close.png" @click="hideModel" mode=""></image>
			</view>
			<view class="top">
				<text class="title">{{notice.dictValue}}</text>
				<text class="desc">{{notice.dictKey}}</text>
			</view>
			<text
				class="label">{{notice.dictDesc}}</text>

		</view>
	</view>
</template>

<script setup>
	import {
		noticeList
	} from '@/util/api.js'
	import {
		onMounted,
		ref
	} from 'vue';
	const page = ref(1)
	const list = ref([])
	const notice = ref()
	onMounted(()=>{
		getList()
	})
	const getList = async ()=>{
		const result = await noticeList({limit:15,page:page.value})
		if(page.value==1){
			list.value = result.data.records
		}else{
			list.value = list.value.concat(result.data.records)
		}
		
	}
	const modelState = ref(false)
	const showModel = (item) => {
		notice.value = item
		modelState.value = true
	}
	const hideModel = () => {
		modelState.value = false
	}
</script>

<style lang="scss" scoped>
	.model {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
		background: rgba(0, 0, 0, 0.5);
		z-index: 1;

		.content {
			width: 750rpx;
			position: absolute;
			background: #FFFFFF;
			border-radius: 40rpx 40rpx 0px 0px;
			top: 220rpx;
			bottom: 0;
			.label {
				color: #181D29;
				font-size: 28rpx;
				display: block;
				width: 686rpx;
				margin: 32rpx auto 0;
				height: calc(100% - 30%);
				// background: red;
				overflow-y: scroll;
			}

			.title {
				color: #181D29;
				font-size: 40rpx;
				font-weight: 500;
				width: 686rpx;
				margin: 0 auto;
				display: block;
			}
			
			.desc {
				color: #A3A7B2;
				font-size: 28rpx;
				display: block;
				width: 686rpx;
				margin: 8rpx auto 0;
			}

			.header {
				display: flex;
				height: 112rpx;
				padding: 0 32rpx;
				align-items: center;
				justify-content: space-between;

				image {
					display: block;
					width: 48rpx;
					height: 48rpx;
				}

				text {
					color: #181D29;
					font-size: 36rpx;
					font-weight: 500;
				}
			}
		}
	}

	.list {
		width: 670rpx;
		margin: 30rpx auto;

		.item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 2rpx solid #F2F4FA;
			height: 128rpx;

			.left {
				display: flex;
				align-items: center;

				text {
					color: #3D3D3D;
					font-size: 32rpx;
				}

				image {
					display: block;
					width: 40rpx;
					height: 40rpx;
					margin-right: 18rpx;
				}
			}

			.right {
				display: flex;
				align-items: center;

				image {
					display: block;
					width: 32rpx;
					height: 32rpx;
					margin-left: 18rpx;
				}

				text {
					color: #A3A7B2;
					font-size: 28rpx;
				}
			}
		}
	}
</style>